<?php
ob_start();
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
require_once('calendar/classes/tc_calendar.php');
include 'operations/connection.php';

?>
<?php
if($_REQUEST['action']){
	$action=$_REQUEST['action'];
	$id=$_REQUEST['idapprovedoc'];
	if($_REQUEST['action']=="editform" || $_REQUEST['action']=="my_declined" || $_REQUEST['action']=="my_sending"){
		$sql="select Tile,EmployeePerforment,TripDate,Location,TotalTime,Content,Description,comment from approvedoc where IDApproveDoc='".$id."'";
		$mangnoidung= mysql_fetch_assoc(mysql_query($sql));
		$fromdate = $mangnoidung[TripDate];
		$femperform=$mangnoidung[EmployeePerforment];
		$flocation=$mangnoidung[Location];
		$ftotaltimef = $mangnoidung[TotalTime];
		$ftitle=$mangnoidung[Tile];
		$fdescription=$mangnoidung[Description];
		$fn222=$mangnoidung[Content];
		$fcomment=$mangnoidung[comment];
		//attach
		$listattachedit = mysql_query('select id, approveid, filepath, filereal, filename, filetype, filesize, createdate from approve_attach where approveid='.$id);
	}else if($_REQUEST['action']=="newform"){
		$fromdate=date("Y-m-d");
		$ftrip_date = "";
		$femperform="";
		$flocation="";
		$ftotaltimef = "";
		$ftitle="";
		$fdescription="";
		$fn222="";
		$fcomment="";
	}
}

?>

<!-- attach -->
<script type="text/javascript" src="attach/js/webtoolkit.aim.js"></script>
<script type="text/javascript" src="attach/js/myattach.js"></script>
<link
	href="attach/css/myattach.css" rel="stylesheet" type="text/css" />
<!-- end attach -->
<script type="text/javascript">
function startCallback() {
	// viết code khi click nút upload và bắt đầu upload.
	$('#attachloading').append ('<?=$l_uploading?>');
	return true;
}


</script>


<script  LANGUAGE="JavaScript" type="text/javascript">
function ch(){
	if(document.f.title.value==""){
		alert('<?=$l_titlemusthavedate?>');
		document.f.title.focus();
		return false;
	}
}

</script>
<script type="text/javascript">
function focusOnMyInputBox(e,ten){
    var x;
    if(window.event) // IE8 and earlier
    	{
    	x=e.keyCode;
    	}
    else if(e.which) // IE9/Firefox/Chrome/Opera/Safari
    	{
    	x=e.which;
    	}
	if(x==13){
		document.getElementById(ten).focus();
		return false;
	}else{
		return true;
	}
}
</script>

<link	href="css/style.css" rel="stylesheet" type="text/css" />
<link	href="calendar/calendar.css" rel="stylesheet" type="text/css" />
<div class="nav_top">
       		<div class="nav_tit"><?php echo $l_assignment_report?></div>     
            <div class="rehome"><a href="mainPhone.php"><?php echo $l_menu?></a></div>       
       	</div>
<form method="post" name="f"  action="newform-handle.php">
	<div class="title"></div>
	<input type="hidden" name='type' value="<?=$type?>" />
	<input type="hidden" name='action' value="<?=$action?>" />
	<input type="hidden" name='id' value="<?=$id?>" />
	<div class="main_content" style="min-height: 895px">
		<ul class="top_but">
			<li>
			<?php if($action=="my_declined" || $action=="my_sending"){?>
				<a href="mydocument-list-mydocument-saved-content"><img src="images/back.png" alt="" /> </a>
			<?php }else{?>
				
			<?php if(isset($_REQUEST['page'])){?>
				<a href="<?=$_SERVER['HTTP_REFERER']?>&page=<?=$_REQUEST['page']?>"><img src="images/back.png" alt="" /> </a>
			<?php }else{?>
				<a href="<?=$_SERVER['HTTP_REFERER']?>"><img src="images/back.png" alt="" /> </a>
			<?php } 
			} ?>
			
			
				<p class="hidden" >
				<?=$l_back?>
				</p>
			</li>
			<li><input type="submit" name="Save" value=""
				style="background: url(images/save.png) no-repeat; width:36px; height: 36px; border: none; position: absolute; top:0px; left:0px; right:0px; bottom:0px; margin: auto" />
				<p class="hidden" >
				<?=$l_save?>
				</p></li>
			<li><input type="submit" name="Send" value=""
				style="background: url(images/send.png) no-repeat; width: 36px; height: 36px; border: none; position: absolute; top:0px; left:0px; right:0px; bottom:0px; margin: auto" />
				<p class="hidden"  >
				<?=$l_send_document?>
				</p></li>
				
			<?php 
			
				if($_REQUEST['action']){
					if($_REQUEST['action']=="editform" || $_REQUEST['action']=="my_declined"){
						?>
						
						<li><input type="submit" name="Delete" value=""
						style="background: url(images/deny.png) no-repeat; width: 36px; height: 36px; border: none; position: absolute; top:0px; left:0px; right:0px; bottom:0px; margin: auto" />
						<p class="hidden" >
						<?=$l_delete?>
						</p></li>
						
						<?php 
					}
				}
			
			?>
		</ul>
		<table class="tcontent" cellpadding="5" cellspacing="0">
			<tr>
				<td class="col_left"><?php echo $l_title?></td>
				<td colspan="3"><input type="text" id="title" name="title" value="<?php echo $ftitle ?>"
					style="height: 24px; width: 100%; border: 1px solid #c4c0c9;line-height: 24px;" onkeypress ="return focusOnMyInputBox(event,'employeeper');"/></td>
			</tr>
			<tr>
				<td class="col_left" width="15%"><?php echo  $l_employee_performent?>
				</td>
				<td><div align="left">
						<input type="text" id="employeeper" name="employeeper" value="<?php echo $femperform?>"
							style="height: 24px; width: 90%; border: 1px solid #c4c0c9;line-height: 24px;" onkeypress ="return focusOnMyInputBox(event,'location');"/>
					</div></td>
				<td class="col_left" width="15%"><?php echo $l_trip_date?></td>
				<td><div align="left">
				<?php
				$myCalendar1 = new tc_calendar("date1", true);
				$myCalendar1->setIcon("calendar/images/iconCalendar.gif");
				$d=split('-',$fromdate,3);
					
				$myCalendar1->setDate($d[2],$d[1],$d[0]);
				$myCalendar1->setPath("calendar/");
				$myCalendar1->setYearInterval(2010, 2015);
				$myCalendar1->dateAllow('2010-01-01', '2015-12-31');
				//$myCalendar1->setHeight(350);
				//$myCalendar1->autoSubmit(true, "form1");
				//$myCalendar1->setSpecificDate(array("2011-04-01", "2011-04-13", "2011-04-25"), 0, 'month');
				$myCalendar1->setOnChange("myChanged('test')");
				//$myCalendar->rtl = true;
				$myCalendar1->writeScript();
					
				//echo $myCalendar1->getDate();

				?>
					</div></td>
			</tr>
			<tr>
				<td class="col_left" width="15%"><?php echo  $l_location?></td>
				<td><div align="left">
						<input type="text" id="location" name="location" value="<?php echo $flocation?>"
							style="height: 24px; width: 90%; border: 1px solid #c4c0c9;line-height: 24px;" onkeypress ="return focusOnMyInputBox(event,'totaltime');"/>
					</div></td>
				<td class="col_left" width="15%"><?php echo  $l_total_time?></td>
				<td><div align="left">
						<input type="text" id="totaltime" name="totaltime" value="<?php echo $ftotaltimef?>"
							style="height: 24px; width: 90%; border: 1px solid #c4c0c9;line-height: 24px;" onkeypress ="return focusOnMyInputBox(event,'description');"/>
					</div></td>
			</tr>
			<tr>
				<td class="col_left" width="15%"><?php echo $l_description?></td>
				<td colspan="3"><textarea rows="3" cols="5" id="description" name="description" 
						style="width: 100%; border: 1px solid #c4c0c9"><?php echo $fdescription?></textarea></td>
			</tr>
			<tr>
				<td class="col_left" width="15%"><?php echo  $l_content?></td>
				<td colspan="3"></td>
			</tr>

			<tr>

				<td colspan="4" style="width:100%">
					<textarea rows="" cols="" id="n222" class="n222" name="n222"  style="width: 100%"><?php echo $fn222;?></textarea>
				<div align="left">
					<div style='float: left'>
						<a  onkeydown="return CKEDITOR.tools.callFunction(0, 12, event);"
						 id=cke_21 class="cke_off cke_button_image"
						   title=Image role=button tabIndex=-1 aria-labelledby=cke_21_label
						   onclick="CKEDITOR.tools.callFunction(17, this); return false;" href="javascript:void('Image')" ? unselectable="on" 
						   >
							  <input class="buttonProject" type="button" style="margin: 5px 0;" value="Insert images" /> 
						  </a>
					</div>
					<div style='float: left;padding-top:2px;margin-left:20px'>
						  <?php include 'attach/attach.php';?>
					</div>
				</div>
				
				</td>

			</tr>
			<tr>
				<td class="col_left" width="15%"><?php echo  $l_comment?></td>
				<td colspan="3"><textarea rows="3" cols="5" name="comment" id="comment" 
						style="width: 100%; border: 1px solid #c4c0c9"><?php echo $fcomment?></textarea></td>
			</tr>
		</table>
	</div>
</form>
<div style="diplay:none">
						 <?php include 'attach/attachhidden.php';?>
				</div>
